<template>
    <div>
        <h2>修改用户</h2>
         <form action="">
            用户名: <input type="text" v-model="user.name"> <br>
            年龄: <input type="text" v-model="user.age">  <br>
            <input type="button" @click="updateUser" value="添加用户"> 
        </form>
    </div>
</template>

<script>
export default {
    data(){
        return{
            user:{
                id: ''
            }
        }
    },
    created(){
        console.log(this.$route.query.id);
        this.$http.get('http://localhost:8989/vue/user/findUserById?id='+this.$route.query.id).then(res=>{
            console.log(res);
            this.user = res.data.data;
        })
        var user = {name: '张三',age: 12};
        this.user = user;
    },
    methods: {
        updateUser(){
            console.log(this.user);
        }
    }
}
</script>